<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
     .txt {
         font-size: 50px;
     }
    </style>
</head>
<body>
    <h1>本地存储 html </h1>
    <input type="text" class="txt">
    <hr>
    <button onclick="myset()">存</button>
    <button onclick="myget()">取</button>
    <button onclick="myclear()">清空</button>
</body>
<script>
function myset(){
    let v =  document.querySelector('.txt').value
    // 存
    localStorage.setItem('stname', v );
    console.log( v );
}
function myget(){
    var v = localStorage.getItem('stname');
    document.querySelector('.txt').value = v ;
}
function myclear(){
    //localStorage.removeItem('stname')  //一个
    localStorage.clear();  //所有
}
</script>
</html>